package org.chronologger.poppaea.client.overlap;

import java.util.Comparator;

public interface Range {
	
	public static final Comparator<Range> byFrom = new Comparator<Range>() {
		public int compare(Range o1, Range o2) {
			return o1.getFrom() - o2.getFrom();
		}
	};
	
	/**
	 * Compares by to, big to small
	 */
	public static final Comparator<Range> byToInverse = new Comparator<Range>() {
		public int compare(Range o1, Range o2) {
			return o2.getTo() - o1.getTo();
		}
	};
	
	public static final Comparator<Range> byTo = new Comparator<Range>() {
		public int compare(Range o1, Range o2) {
			return o1.getTo() - o2.getTo();
		}
	};
	

	public static class Tools {
		
		public static boolean overlapping(Range a, Range b) {
			if(a.getFrom() > b.getFrom())
				return overlapping(b, a);
			return a.getTo() > b.getFrom();
		}
		
	}
	
	public int getFrom();
	public int getTo();
	
}